package com.yantong.constant;

import java.util.*;

/**
 * 商品类型
 */
public enum CategoryType {
    huodongleimu(1, "活动类目"),
    qiantaileimu(2, "前台类目"),
    houtaileimu(3, "后台类目"),
    zhuyeleimu(4, "主页类目"),
    waimaileimu(5, "外卖类目"),
    //添加修正商品类型
    tangshileimu(6, "堂食类目"),
    zitileimu(7, "自提类目"),;


    private int type;
    private String name;


    private static Map<Integer, String> all = new HashMap<>();

    static {
        for (CategoryType ticketType : EnumSet.allOf(CategoryType.class)) {
            all.put(ticketType.type, ticketType.name);
        }
    }

    public static String get(Integer code) {
        return all.get(code);
    }


    public static List<Map<String, Object>> listTicketTypes() {
        List<Map<String, Object>> list = new ArrayList<>();

        for (CategoryType ticketType : EnumSet.allOf(CategoryType.class)) {
            Map<String, Object> item = new HashMap<>();
            item.put("type", ticketType.getType());
            item.put("name", ticketType.getName());
            list.add(item);
        }
        return list;
    }

    CategoryType(int type, String name) {
        this.type = type;
        this.name = name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
